<?php
	// start the session
  	session_start();
	
	// inclue the s3 class library
  	require_once("class.s3.php");
?> 
<!-- *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+ -->
<!-- File: contents.php																							-->
<!--																											-->
<!-- Author: John Fronckowiak, IDC Consulting, Inc.																-->
<!--																											-->
<!-- Purpose: Retrieve the contents of the bucket specified in the URL.											-->
<!-- *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+ -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!-- set the iPhone viewport -->
	<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
	
	<!-- include the iui style sheet and javascript -->
	<style type="text/css" media="screen">@import "lib/iui/iui.css";</style>
    <script type="application/x-javascript" src="lib/iui/iui.js"></script>		

	<title>Amazon Web Services Manager</title>
</head>

<body>
<ul id="contents" title="Contents" selected="true">
<?php
	// create an S3 object
  	$s3 = new S3($HTTP_SESSION_VARS["AMAZON_KEY"], $HTTP_SESSION_VARS["AMAZON_PRIVATE_KEY"]);
	
	// retrieve the bucket name
  	$bucket_name = $_GET['bucket'];

	// get the contents of the bucket
  	$items = $s3->getBucketContents($bucket_name, str_replace("//", "/", "/$path/"), "/");

	// is the bucket empty?
  	if (count($items) == 0) {
      	echo "<li>$bucket_name is empty.</li>";
  	} else {
		// loop through each bucket item
      	foreach ($items as $item) {
			// allow each item to be deleted
          	echo "<li><a href='deleteobj.php?bucket=$bucket_name&item={$item["name"]}'>{$item["name"]}</a></li>";
      	}
  	}
?>
</ul>
</body>
</html>